package cn.cdutetc.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

@WebServlet(name = "RegisterServlet", value = "/register")
public class RegisterServlet extends HttpServlet {
    @Override
    public void init(ServletConfig config) throws ServletException {
        super.init(config);


            try {
                InputStream in=config.getServletContext().getResourceAsStream("/WEB-INF/classes/jdbc.properties");
                Properties p=new Properties();
                p.load(in);
                String url=p.getProperty("url");
                String userName=p.getProperty("username");
                String pwd=p.getProperty("password");
                Class.forName(p.getProperty("drivername"));
                System.out.println(userName);
            } catch (ClassNotFoundException | IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }


    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          HttpSession  s=request.getSession(true);
          s.setAttribute("username",request.getParameter("user"));
          request.getRequestDispatcher("/index.jsp").forward(request,response);

    }
}
